/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pio.action.coordinador;

import DBMS.DataBaseManager;
import clases.ContactoCoordinador;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

/**
 *
 * @author tamerdark
 */
public class Contactar extends DispatchAction {
    
    public ActionForward populate(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        Comun.fillInstituciones(request);
        return mapping.findForward("page");
    }
    
    public ActionForward save(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        Comun.fillInstituciones(request);
        ContactoCoordinador cc = (ContactoCoordinador) form;
        DataBaseManager dbms = DataBaseManager.getInstance();
        if(dbms.agregarContactoCoordinador(cc)){
            cc.setMensaje("Mensaje enviado.");
            return mapping.findForward("success");
        }else{            
            cc.setMensaje("Error al enviar mensaje. Por favor intentelo mas tarde");
            return mapping.findForward("failure");
        }           
    }
    
}
